<?php
    require('config/config.php');
    include('header.php');
		
	

?>	
    <!-- Header -->
    <header class="container_12 " id="header">
        <div class=" grid_3 alpha">
            <img src="./stylesheets/images/logo1.png" alt="Logo"/>
        </div>
	
<?php
    require 'tableauCriticite.php';
?>
    </header>
    <!-- End Header -->
    <!-- Content -->
    <div class="clear"></div>
    <section class="content">
<?php
    require 'menu.php';
?>
             <table class="tabInfos">
                <caption>Détails de toutes les machines</caption>
                <thead>
                    <tr>
                      <th>Machine</th>
                      <th>Service</th>
                      <th>Statut</th>
                      <th>Dernier check</th>
                      <th>Durée</th>
                      <th>Informations</th>
                    </tr>
                </thead>
                <tbody>
<?php			
				$now = new DateTime();
				$dayNow = (int)$now->format('j');
				$checkNom = "";
				foreach($tabInfo as $info) {
					
					$stringToDate = DateTime::createFromFormat('Y-m-j H:i:s',  $info['checkD']);
					$interval = $stringToDate->diff($now);
					$dayRow = (int)$stringToDate->format('j');
					$lastModif = $interval->d."j ". $interval->h ."h ". $interval->i ."m ". $interval->s ."s";
					
					echo '<tr>';
					if($checkNom != $info['machine']){
						echo '<td><a href="detailPoste.php?machineID='.$info['idM'].'">'.$info['machine'].'</a></td>';
						$checkNom = $info['machine'];
					}else{
						echo '<td></td>';
					}
                     echo '<td>'.$info['service'].'</td>';
                     echo '<td>'.$info['status'].'</td>';
					 echo '<td>'.$info['checkD'].'</td>';
					 echo '<td>'. $lastModif .'</td>';
                     echo '<td><p>' .$info['infos']. '</p></td>';
                     echo '</tr>';
				}
?>
                </tbody>
            </table>
    </section>
    <!-- End Content-->
 <?php
    include 'footer.php';
 ?>
</body>
</html>
